﻿using System.Windows;
using DaphneProfiBase;
using GalaSoft.MvvmLight.Messaging;

namespace DaphneForms
{
    /// <summary>
    /// Description for PDNGameList.
    /// </summary>
    public partial class PDNGameList : Window
    {
        /// <summary>
        /// Initializes a new instance of the PDNGameList class.
        /// </summary>
        public PDNGameList()
        {
            InitializeComponent();

            // register message for closing the form
            Messenger.Default.Register<NotificationMessage>(this, (nm) =>
            {
                if (nm.Notification == Notify.CloseForm && nm.Sender == this.DataContext)
                {
                    Close();
                }
                if (nm.Notification == Notify.ResetDataGrid && nm.Sender == this.DataContext)
                {
                    var itemsSource = uxDataGrid.ItemsSource;
                    uxDataGrid.ItemsSource = null;
                    uxDataGrid.ItemsSource = itemsSource;
                }
            });

        }
    }
}